home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / DrawPrxy.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  20.6 KB  |  671 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPrxy.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef DRAWPRXY_H
  15. #include "DrawPrxy.h"
  16. #endif
  17.  
  18. #ifndef DRAWPART_H
  19. #include "DrawPart.h"
  20. #endif
  21.  
  22. #ifndef DRAWFRM_H
  23. #include "DrawFrm.h"
  24. #endif
  25.  
  26. #ifndef BASESHP_H
  27. #include "BaseShp.h"
  28. #endif
  29.  
  30. #ifndef BOUNDSHP_H
  31. #include "BoundShp.h"
  32. #endif
  33.  
  34. #ifndef LINESHP_H
  35. #include "LineShp.h"
  36. #endif
  37.  
  38. #ifndef OVALSHP_H
  39. #include "OvalShp.h"
  40. #endif
  41.  
  42. #ifndef RECTSHP_H
  43. #include "RectShp.h"
  44. #endif
  45.  
  46. #ifndef RRECTSHP_H
  47. #include "RRectShp.h"
  48. #endif
  49.  
  50. #ifndef TEXTSHP_H
  51. #include "TextShp.h"
  52. #endif
  53.  
  54. #ifndef DRAWCLIP_H
  55. #include "DrawClip.h"
  56. #endif
  57.  
  58. #ifndef UTILS_H
  59. #include "Utils.h"
  60. #endif
  61.  
  62. // ----- Part Layer -----
  63.  
  64. #ifndef FWITERS_H
  65. #include "FWIters.h"
  66. #endif
  67.  
  68. #ifndef FWPXYITE_H
  69. #include "FWPxyIte.h"
  70. #endif
  71.  
  72. #ifndef FWUTIL_H
  73. #include "FWUtil.h"
  74. #endif
  75.  
  76. #ifndef FWPART_H
  77. #include "FWPart.h"
  78. #endif
  79.  
  80. #ifndef FWPRTITE_H
  81. #include "FWPrtIte.h"
  82. #endif
  83.  
  84. #ifndef FWPRESEN_H
  85. #include "FWPresen.h"
  86. #endif
  87.  
  88. #ifndef FWPXYFRM_H
  89. #include "FWPxyFrm.h"
  90. #endif
  91.  
  92. // ----- OS Layer -----
  93.  
  94. #ifndef FWRECT_H
  95. #include "FWRect.h"
  96. #endif
  97.  
  98. #ifndef FWODGEOM_H
  99. #include "FWODGeom.h"
  100. #endif
  101.  
  102. #ifndef FWEVENT_H
  103. #include "FWEvent.h"
  104. #endif
  105.  
  106. // ----- Foundation Includes -----
  107.  
  108. #ifndef FWSTREAM_H
  109. #include "FWStream.h"
  110. #endif
  111.  
  112. // ----- OpenDoc Includes -----
  113.  
  114. #ifndef SOM_ODShape_xh
  115. #include <Shape.xh>
  116. #endif
  117.  
  118. #ifndef SOM_ODTransform_xh
  119. #include <Trnsform.xh>
  120. #endif
  121.  
  122. //========================================================================================
  123. //    Runtime Information
  124. //========================================================================================
  125.  
  126. #ifdef FW_BUILD_MAC
  127. #pragma segment odfdraw
  128. #endif
  129.  
  130. FW_DEFINE_AUTO(CProxyShape)
  131. FW_DEFINE_CLASS_M1(CProxyShape, CRectShape)
  132.  
  133. const FW_ClassTypeConstant LProxyShape = FW_TYPE_CONSTANT('s','h','p','x');
  134. FW_REGISTER_ARCHIVABLE_CLASS(LProxyShape, CProxyShape, CProxyShape::Read, 0, 0, CBaseShape::Write)
  135.  
  136. //========================================================================================
  137. //    CProxyShape
  138. //========================================================================================
  139.  
  140. //----------------------------------------------------------------------------------------
  141. //    CProxyShape::CProxyShape
  142. //----------------------------------------------------------------------------------------
  143.  
  144. CProxyShape::CProxyShape(Environment* ev, const FW_CRect& rect, CDrawPart* drawPart) :
  145.     CRectShape(drawPart, kProxyShape, kFillOnly),
  146.     FW_MProxy(ev, drawPart),
  147.     fFrozen(FALSE),
  148.     fFrameRect(rect)
  149. {
  150.     SetRectGeometry(rect);
  151.     
  152.     FW_END_CONSTRUCTOR
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. // CProxyShape::CProxyShape
  157. //----------------------------------------------------------------------------------------
  158.  
  159. CProxyShape::CProxyShape(Environment* ev, CDrawPart* drawPart, FW_CReadableStream& archive) :
  160.     CRectShape(drawPart, archive),
  161.     FW_MProxy(ev, drawPart),
  162.     fFrozen(FALSE)
  163. {
  164.     archive >> fFrameRect;
  165.  
  166.     FW_END_CONSTRUCTOR
  167. }
  168.  
  169. //----------------------------------------------------------------------------------------
  170. // CProxyShape::~CProxyShape
  171. //----------------------------------------------------------------------------------------
  172.  
  173. CProxyShape::~CProxyShape()
  174. {
  175.     FW_START_DESTRUCTOR
  176. }
  177.     
  178. //----------------------------------------------------------------------------------------
  179. //    CProxyShape::FrameShapeRequested
  180. //----------------------------------------------------------------------------------------
  181.  
  182. ODShape* CProxyShape::FrameShapeRequested(Environment* ev, 
  183.                                         FW_CEmbeddingFrame* embeddingFrame, 
  184.                                         ODFrame* odEmbeddedFrame, 
  185.                                         ODShape* requestedFrameShape)
  186. {
  187. FW_UNUSED(embeddingFrame);
  188.     // ----- get the bounding box of the asked frame shape
  189.     FW_CRect frameRect = FW_GetShapeBoundingBox(ev, requestedFrameShape);
  190.     
  191.     fFrameRect.right = fFrameRect.left + frameRect.Width();
  192.     fFrameRect.bottom = fFrameRect.top + frameRect.Height();
  193.  
  194.     // ----- Invalidate the old used Shape in case the embedded frame doesn't do it-----
  195.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  196.     odEmbeddedFrame->Invalidate(ev, aqUsedShape, NULL);
  197.     
  198.     // ----- Don't forget to bump the refcount
  199.     requestedFrameShape->Acquire(ev);
  200.     return requestedFrameShape;
  201. }
  202.  
  203. //----------------------------------------------------------------------------------------
  204. //    CProxyShape::UsedShapeChanged
  205. //----------------------------------------------------------------------------------------
  206.  
  207. void CProxyShape::UsedShapeChanged(Environment* ev, FW_CEmbeddingFrame* embeddingFrame, ODFrame* odEmbeddedFrame)
  208. {
  209.     FW_CAcquiredODShape aqFrameShape = odEmbeddedFrame->AcquireFrameShape(ev, NULL);
  210.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  211.     
  212.     FW_CRect usedShapeRect = FW_GetShapeBoundingBox(ev, aqUsedShape);
  213.     FW_CRect newShapeRect = FW_GetShapeBoundingBox(ev, aqFrameShape);
  214.  
  215.     newShapeRect.Intersection(usedShapeRect);    
  216.     newShapeRect.Offset(fFrameRect.left, fFrameRect.top);
  217.  
  218.     // ----- Get previous update shape -----
  219.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev);
  220.     GetUpdateBox(ev, aqInvalidShape);
  221.  
  222.     // ----- Set the geometry of the shape -----
  223.     SetRectGeometry(newShapeRect);
  224.         
  225.     // ----- Calculate the shape to update union minus intersection
  226.     {
  227.         FW_CAcquiredODShape aqNewUpdateBox = ::FW_NewODShape(ev);
  228.         GetUpdateBox(ev, aqNewUpdateBox);
  229.         
  230.         FW_CAcquiredODShape aqIntersect(aqInvalidShape->Copy(ev));
  231.         aqIntersect->Intersect(ev, aqNewUpdateBox);
  232.         
  233.         aqInvalidShape->Union(ev, aqNewUpdateBox);
  234.         
  235.         // ----- Clip our embedded facets using the union
  236.         CDrawFacetClipper facetClipper(fDrawPart);
  237.         facetClipper.Clip(ev, embeddingFrame, aqInvalidShape);
  238.  
  239.         aqInvalidShape->Subtract(ev, aqIntersect);
  240.     }
  241.     
  242.     fDrawPart->GetMainPresentation()->Invalidate(ev, aqInvalidShape);
  243.     
  244.     // ----- Invalidate the difference
  245.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  246. }
  247.  
  248. //----------------------------------------------------------------------------------------
  249. //    CProxyShape::MoveBefore
  250. //----------------------------------------------------------------------------------------
  251.  
  252. void CProxyShape::MoveBefore(Environment* ev, CProxyShape* before)
  253. {
  254. FW_UNUSED(ev);
  255. FW_UNUSED(before);
  256.  
  257. /*
  258.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  259.     FW_CAcquiredODPart aqBeforePart = before->AcquireEmbeddedPart(ev);
  260.  
  261.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  262.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  263.     {
  264.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  265.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  266.         {
  267.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  268.             if (aqODPart == aqEmbeddedPart)
  269.             {
  270.                 FW_CFacetIterator ite2(ev, facet, kODChildrenOnly, kODFrontToBack);
  271.                 for (ODFacet* facet2 = ite2.First(ev); ite2.IsNotComplete(ev); facet2 = ite2.Next(ev))
  272.                 {
  273.                     FW_CAcquiredODPart aqODPart2 = facet2->GetFrame(ev)->AcquirePart(ev);
  274.                     if (aqODPart2 == aqBeforePart)
  275.                     {
  276.                         facet->MoveBefore(ev, facet1, facet2);
  277.                         break;
  278.                     }
  279.                 }
  280.             }
  281.         }
  282.     }
  283. */
  284. }
  285.  
  286. //----------------------------------------------------------------------------------------
  287. //    CProxyShape::MoveBehind
  288. //----------------------------------------------------------------------------------------
  289.  
  290. void CProxyShape::MoveBehind(Environment* ev, CProxyShape* behind)
  291. {
  292. FW_UNUSED(ev);
  293. FW_UNUSED(behind);
  294.  
  295. /*    
  296.     FW_CAcquiredODPart aqEmbeddedPart = AcquireEmbeddedPart(ev);
  297.     FW_CAcquiredODPart aqBehindPart = behind->AcquireEmbeddedPart(ev);
  298.  
  299.     FW_CPresentationFacetIterator ite(ev, fDrawPart->GetMainPresentation());
  300.     for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
  301.     {
  302.         FW_CFacetIterator ite1(ev, facet, kODChildrenOnly, kODFrontToBack);
  303.         for (ODFacet* facet1 = ite1.First(ev); ite1.IsNotComplete(ev); facet1 = ite1.Next(ev))
  304.         {
  305.             FW_CAcquiredODPart aqODPart = facet1->GetFrame(ev)->AcquirePart(ev);
  306.             if (aqODPart == aqEmbeddedPart)
  307.             {
  308.                 FW_CFacetIterator ite2(ev, facet1, kODChildrenOnly, kODFrontToBack);
  309.                 for (ODFacet* facet2 = ite2.First(ev); ite2.IsNotComplete(ev); facet2 = ite2.Next(ev))
  310.                 {
  311.                     FW_CAcquiredODPart aqODPart2 = facet2->GetFrame(ev)->AcquirePart(ev);
  312.                     if (aqODPart2 == aqBehindPart)
  313.                     {
  314.                         facet->MoveBehind(ev, facet1, facet2);
  315.                         break;
  316.                     }
  317.                 }
  318.             }
  319.         }
  320.     }
  321. */
  322. }
  323.  
  324. //----------------------------------------------------------------------------------------
  325. // CProxyShape::RestoreShape
  326. //----------------------------------------------------------------------------------------
  327.  
  328. void CProxyShape::RestoreShape(Environment *ev)
  329. {
  330.     CRectShape::RestoreShape(ev);
  331.     
  332.     AttachEmbeddedFrames(ev);
  333. }
  334.  
  335. //----------------------------------------------------------------------------------------
  336. // CProxyShape::Removed
  337. //----------------------------------------------------------------------------------------
  338. //     the shape is going to be removed (for example for undo)
  339.  
  340. void CProxyShape::Removed(Environment* ev)
  341. {
  342.     FW_ASSERT(!this->IsDetached(ev));
  343.     
  344.     CRectShape::Removed(ev);
  345.     
  346.     DetachEmbeddedFrames(ev);
  347. }
  348.  
  349. //----------------------------------------------------------------------------------------
  350. // CProxyShape::Deleted
  351. //----------------------------------------------------------------------------------------
  352. //     the shape is going to be deleted
  353.  
  354. void CProxyShape::Deleted(Environment* ev)
  355. {
  356.     CRectShape::Deleted(ev);
  357.     
  358.     RemoveEmbeddedFrames(ev);
  359. }
  360.  
  361. //----------------------------------------------------------------------------------------
  362. // CProxyShape::Flatten
  363. //----------------------------------------------------------------------------------------
  364.  
  365. void CProxyShape::Flatten(FW_CWritableStream& archive)
  366. {    
  367.     CRectShape::Flatten(archive);
  368.     
  369.     archive << fFrameRect;
  370.  
  371.     // [HLX] I know it's bad but I know I am archiving to a storage unit
  372.     CDrawWritableStream* drawArchive = (CDrawWritableStream*)&archive;
  373.     Externalize(drawArchive->GetEnvironment(), drawArchive->GetStorageUnitView(), drawArchive->GetCloneInfo());
  374. }
  375.  
  376. //----------------------------------------------------------------------------------------
  377. // CProxyShape::RenderShape
  378. //----------------------------------------------------------------------------------------
  379. //    Important Note: embedded frame during printing are not clipped because I draw them in z-ordering
  380.  
  381. void CProxyShape::RenderShape(Environment *ev, ODFacet* facet, FW_CGraphicContext& gc)
  382. {        
  383.     FW_CAcquiredODShape aqTempClipShape(gc.AcquireClip());    // AcquireClip returns a copy in content coordinate
  384.  
  385.     FW_CProxyFacetIterator ite(ev, this, facet, kODBackToFront);
  386.     ODFacet* embeddedODFacet = ite.First(ev);        // I know I create only one embedded Facets
  387.     
  388.     if (embeddedODFacet != NULL)
  389.     {
  390.         {
  391.             FW_CAcquiredODTransform aqFrameTransform = embeddedODFacet->AcquireExternalTransform(ev, NULL);
  392.             aqTempClipShape->InverseTransform(ev, aqFrameTransform);    // parent content (me) -> embedded frame
  393.         }
  394.                     
  395. #ifdef FW_BUILD_WIN
  396.         // [HLX] bug in windows? the invalidShape is expected to be in pixels instead of points
  397.         FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  398.         aqTempShape->Outset(ev, ff(1));    // [HLX] Because of rounding errors
  399.         FW_CGraphicDevice *device = gc.GetGraphicDevice();
  400.         device->PointToPixel(ev, aqTempShape);
  401. #endif
  402.         
  403.         // ----- Because we are calling the draw method of an embedded facet, we want
  404.         // ----- to save our context. The embedded facet will be using the same grafport 
  405.         // ----- and may not be restoring it
  406.         FW_CSaveRestoreContext src(gc);
  407.     
  408.         embeddedODFacet->Draw(ev, aqTempClipShape, NULL);
  409.         embeddedODFacet->DrawChildren(ev, aqTempClipShape, NULL);
  410.     }
  411.     else
  412.     {
  413.         FW_CRect rect = GetRectGeometry();
  414.         FW_CRectShape::RenderRect(gc, rect, FW_kFill, FW_kRGBLightGray, FW_CStyle(FW_kFixedPos1, FW_kAntPat));
  415.         FW_CRectShape::RenderRect(gc, rect, FW_kFrame);
  416.     }
  417. }
  418.  
  419. //----------------------------------------------------------------------------------------
  420. // CProxyShape::AdjustRectForPenSize
  421. //----------------------------------------------------------------------------------------
  422.  
  423. void CProxyShape::AdjustRectForPenSize(FW_CRect& rect, FW_Fixed penSize) const
  424. {
  425. FW_UNUSED(rect);
  426. FW_UNUSED(penSize);
  427.     // Does nothing because I have a pensize of zero
  428. }
  429.  
  430. //----------------------------------------------------------------------------------------
  431. // CProxyShape::MapShape
  432. //----------------------------------------------------------------------------------------
  433.  
  434. void CProxyShape::MapShape(Environment *ev, const FW_CRect& srcRect, const FW_CRect& dstRect)
  435. {
  436.     CRectShape::MapShape(ev, srcRect, dstRect);    
  437.     
  438.     fFrameRect = GetRectGeometry();
  439.         
  440.     // ----- Resize every embedded frames -----
  441.     ChangeExternalTransforms(ev, fFrameRect.left, fFrameRect.top);
  442.     ChangeFrameShapes(ev, fFrameRect.right - fFrameRect.left, fFrameRect.bottom - fFrameRect.top);    
  443. }
  444.  
  445. //----------------------------------------------------------------------------------------
  446. // CProxyShape::OffsetShape
  447. //----------------------------------------------------------------------------------------
  448.  
  449. void CProxyShape::OffsetShape(Environment *ev, FW_Fixed xDelta, FW_Fixed yDelta)
  450. {    
  451.     CRectShape::OffsetShape(ev, xDelta, yDelta);
  452.     
  453.     fFrameRect.Offset(xDelta, yDelta);
  454.     
  455.     // ----- Change the external transform of all embedded facets -----
  456.     ChangeExternalTransforms(ev, fFrameRect.left, fFrameRect.top);
  457. }
  458.         
  459. //----------------------------------------------------------------------------------------
  460. // CProxyShape::SelectShape
  461. //----------------------------------------------------------------------------------------
  462.  
  463. void CProxyShape::SelectShape(Environment *ev, FW_Boolean state)
  464. {
  465.     CBaseShape::SelectShape(ev, state);
  466.     
  467.     // ----- Select all the embedded facet ----
  468.     SetSelectState(ev, state);
  469. }
  470.  
  471. //----------------------------------------------------------------------------------------
  472. // CProxyShape::SetFrozen
  473. //----------------------------------------------------------------------------------------
  474.  
  475. FW_Boolean CProxyShape::SetFrozen(FW_Boolean state)
  476. {
  477.     if (fFrozen != state)
  478.     {
  479.         fFrozen = state;    
  480.         return TRUE;
  481.     }
  482.     
  483.     return FALSE;
  484. }
  485.  
  486. //----------------------------------------------------------------------------------------
  487. // CProxyShape::IsFrozen
  488. //----------------------------------------------------------------------------------------
  489.  
  490. FW_Boolean CProxyShape::IsFrozen() const
  491. {
  492.     return fFrozen;
  493. }
  494.  
  495. //----------------------------------------------------------------------------------------
  496. // CProxyShape::Read
  497. //----------------------------------------------------------------------------------------
  498.  
  499. void* CProxyShape::Read(FW_CReadableStream& stream, FW_ClassTypeConstant type)
  500. {
  501. FW_UNUSED(type);
  502.     // [HLX] This is a hack until I can register object with the archiver
  503.     CDrawReadableStream *drawArchive = (CDrawReadableStream*)&stream;
  504.     CProxyShape* proxyShape = FW_NEW(CProxyShape, (drawArchive->GetEnvironment(), drawArchive->GetDrawPart(), stream));
  505.     
  506.     proxyShape->Internalize(drawArchive->GetEnvironment(), drawArchive->GetStorageUnitView(), drawArchive->GetCloneInfo());
  507.     
  508.     return proxyShape;
  509. }
  510.  
  511. //----------------------------------------------------------------------------------------
  512. // CProxyShape::SubtractToWorkingClip
  513. //----------------------------------------------------------------------------------------
  514. //    ATTENTION: windowClip is in Content coordinates. tempShape is just a working shape. It is
  515. //    used by CBaseShape so I don't have to allocate a shape every time.
  516.  
  517. void CProxyShape::SubtractToWorkingClip(Environment *ev, 
  518.                                         CDrawFacetClipper* facetClipper, 
  519.                                         ODFacet* containingFacet, 
  520.                                         ODShape* workingClip, 
  521.                                         ODShape* tempShape,
  522.                                         ODShape* limitShape)
  523. {
  524. FW_UNUSED(tempShape);
  525.  
  526.     FW_CProxyFacetIterator ite(ev, this, containingFacet, kODFrontToBack);
  527.     for (ODFacet *embeddedODFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedODFacet = ite.Next(ev))
  528.     {
  529.         facetClipper->ClipOneEmbeddedFacet(ev, embeddedODFacet, workingClip, limitShape);
  530.     }
  531. }
  532.  
  533. //----------------------------------------------------------------------------------------
  534. // CProxyShape::ChangeRenderVerb
  535. //----------------------------------------------------------------------------------------
  536.  
  537. void CProxyShape::ChangeRenderVerb(Environment *ev, unsigned short renderVerb)
  538. {
  539. FW_UNUSED(ev);
  540. FW_UNUSED(renderVerb);
  541.  
  542.     // We don't do anything
  543. }
  544.  
  545. //----------------------------------------------------------------------------------------
  546. // CProxyShape::SetSubscribeLink
  547. //----------------------------------------------------------------------------------------
  548.  
  549. void CProxyShape::SetSubscribeLink(Environment* ev, CDrawSubscribeLink* subscribeLink)
  550. {
  551.     CBaseShape::SetSubscribeLink(ev, subscribeLink);
  552.     ChangeLinkStatus(ev, subscribeLink ? kODInLinkDestination : kODNotInLink);
  553. }
  554.  
  555. //----------------------------------------------------------------------------------------
  556. // CProxyShape::SetPublishLink
  557. //----------------------------------------------------------------------------------------
  558.  
  559. void CProxyShape::SetPublishLink(Environment* ev, CDrawPublishLink* publishLink)
  560. {
  561.     CBaseShape::SetPublishLink(ev, publishLink);
  562.     ChangeLinkStatus(ev, publishLink ? kODInLinkSource : kODNotInLink);
  563. }
  564.  
  565.  
  566. //----------------------------------------------------------------------------------------
  567. // CProxyShape::IsInLinkDestination
  568. //----------------------------------------------------------------------------------------
  569.  
  570. FW_Boolean CProxyShape::IsInLinkDestination(Environment* ev)
  571. {
  572.     // Check our local link status
  573.     if (this->IsSubscribed())
  574.         return TRUE;
  575.  
  576.     // Check the frame's link status
  577.     FW_CProxyProxyFrameIterator iter(this);
  578.     FW_CProxyFrame* frame = iter.First();    // only need to check one frame
  579.     if (frame->GetFrame(ev)->GetLinkStatus(ev) == kODInLinkDestination)
  580.         return TRUE;
  581.  
  582.     return FALSE;
  583. }
  584.  
  585. //----------------------------------------------------------------------------------------
  586. //    CProxyShape::NeedFacets
  587. //----------------------------------------------------------------------------------------
  588. //    The simplest way to test if my proxy needs facet is to intersect the visible content
  589. //    with the shape of the proxy.
  590. FW_Boolean CProxyShape::NeedFacets(Environment *ev, FW_CEmbeddingFrame* embeddingFrame) const
  591. {
  592.     FW_CRect bounds = embeddingFrame->GetContentView(ev)->GetBoundsInContent(ev);
  593.     FW_CRect rect = GetRectGeometry();
  594.     return rect.IsIntersecting(bounds);
  595. }
  596.  
  597. //----------------------------------------------------------------------------------------
  598. //    CProxyShape::CreateFacets
  599. //----------------------------------------------------------------------------------------
  600.  
  601. short CProxyShape::CreateFacets(Environment* ev,
  602.                                 FW_CEmbeddingFrame* embeddingFrame,
  603.                                 ODFacet* embeddingFacet,
  604.                                 ODFrame* embeddedFrame,
  605.                                 ODShape* proposedClipShape)
  606. {
  607. FW_UNUSED(embeddingFrame);
  608.     FW_CRect embeddedFrameBounds = GetFrameRect(ev);
  609.     
  610.     FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, embeddedFrameBounds.TopLeft());
  611.  
  612.     CreateFacet(ev,
  613.                 embeddingFacet,
  614.                 embeddedFrame,
  615.                 proposedClipShape,
  616.                 aqExternalTransform,
  617.                 NULL,                    // Canvas
  618.                 NULL,                    // biasCanvas
  619.                 NULL,                    // siblingFacet
  620.                 kODFrameInFront);
  621.     
  622.     return 1;    // one facet created
  623. }
  624.  
  625. //----------------------------------------------------------------------------------------
  626. //    CDrawFrame::RevealFrame
  627. //----------------------------------------------------------------------------------------
  628. //    Attention revealShape is in embedded frame coordinate
  629.  
  630. FW_Boolean CProxyShape::Reveal(Environment *ev, 
  631.                                FW_CEmbeddingFrame* embeddingFrame,
  632.                                ODFrame* embeddedFrame, 
  633.                                ODShape* revealShape)
  634. {
  635. FW_UNUSED(embeddedFrame);
  636.  
  637.     FW_ASSERT(revealShape);
  638.     
  639.     // bounds is in embedded frame coordinate
  640.     FW_CRect bounds = FW_GetShapeBoundingBox(ev, revealShape);
  641.     
  642.     // Convert bounds to content coordinate
  643.     FW_CRect embeddedFrameBounds = GetFrameRect(ev);
  644.     bounds.Offset(embeddedFrameBounds.left, embeddedFrameBounds.top);
  645.     
  646.     embeddingFrame->GetScroller(ev)->RevealRect(ev, bounds);
  647.  
  648.     return TRUE;
  649. }
  650.  
  651. //----------------------------------------------------------------------------------------
  652. // CProxyShape::MakePurgeable
  653. //----------------------------------------------------------------------------------------
  654.  
  655. void CProxyShape::MakePurgeable(Environment* ev, CDrawFrame* drawFrame, const FW_CRect& bounds)
  656. {
  657.     FW_CRect rect = GetRectGeometry();
  658.     SetPurgeable(ev, drawFrame, !rect.IsIntersecting(bounds));
  659. }
  660.  
  661. //----------------------------------------------------------------------------------------
  662. // CProxyShape::ShapeCommitPasteDone
  663. //----------------------------------------------------------------------------------------
  664.  
  665. void CProxyShape::ShapeCommitPasteDone(Environment* ev)
  666. {
  667.     this->CommitPasteDone(ev);
  668. }
  669.  
  670.  
  671.